package com.nokia.pc3.core.dac;

import java.util.ArrayList;

import org.codehaus.jackson.annotate.JsonProperty;

import com.nokia.pc3.core.exception.XFormException;
import com.nokia.pc3.core.xform.Xformation;

public class DAC {

	private String xformSeriesName;
	private String xformSeriesVersion;
	private ArrayList<Xformation> xformation;

	@JsonProperty("xformSeriesName")
	public String getXformSeriesName() {
		return xformSeriesName;
	}

	@JsonProperty("xformSeriesName")
	public void setXformSeriesName(String xformSeriesName) {
		this.xformSeriesName = xformSeriesName;
	}

	@JsonProperty("xformSeriesVersion")
	public String getXformSeriesVersion() {
		return xformSeriesVersion;
	}

	@JsonProperty("xformSeriesVersion")
	public void setXformSeriesVersion(String xformSeriesVersion) {
		this.xformSeriesVersion = xformSeriesVersion;
	}

	@JsonProperty("xformation")
	public ArrayList<Xformation> getXformation() {
		return xformation;
	}

	public ArrayList<Xformation> getXformationType(String xformtype) {
		ArrayList<Xformation> xformsOfType = new ArrayList<Xformation>();
		for (Xformation xf : xformation) {
			if (xf.getXformType().equals(xformtype)) {
				xformsOfType.add(xf);
			}
		}
		return xformsOfType;
	}

	public Xformation getXformation(String xformName) throws XFormException {
		Xformation xform = null;
		for (Xformation xf : xformation) {
			if (xf.getXformName().equals(xformName)) {
				xform = xf;
				break;
			}
		}
		if (xform == null) {
			throw new XFormException("XFormation for name: " + xformName
					+ "doesn't exist.");
		}
		return xform;
	}

	@JsonProperty("xformation")
	public void setXformation(ArrayList<Xformation> xformation) {
		this.xformation = xformation;
	}

}
